package cn.wolfcode.wolf2w.controller;


import cn.wolfcode.wolf2w.annotation.RequireLogin;
import cn.wolfcode.wolf2w.annotation.UserParam;
import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.query.BannerQueryObject;
import cn.wolfcode.wolf2w.query.TravelQueryObject;
import cn.wolfcode.wolf2w.redis.service.IUserinfoRedisService;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import cn.wolfcode.wolf2w.util.UMEditorUploader;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/index")
public class IndexController {
    @Autowired
    private ITravelService travelService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IBannerService bannerService;

    @GetMapping("/banners/travel")
    public Object banners_travel(@ModelAttribute("qo") BannerQueryObject qo) {
        List<Banner> query = bannerService.listAtNum(1);
        return JsonResult.success(query);
    }
    @GetMapping("/banners/strategy")
    public Object banners_strategy(@ModelAttribute("qo") BannerQueryObject qo) {
        List<Banner> query = bannerService.listAtNum(2);
        Banner banner = query.get(0);
        return JsonResult.success(banner);
    }


    @PostMapping("/saveOrUpdate")
    public Object saveOrUpdate(Travel travel, /*HttpServletRequest request*/@UserParam UserInfo token1) {
        travelService.saveOrUpdate(travel, token1);
        System.out.println(token1);
        return JsonResult.success(travel);
    }


}
